package org.utils.log;

import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Layout;
import org.apache.log4j.spi.LoggingEvent;
import org.utils.debug.DebugFrame;

public class FrameAppender extends AppenderSkeleton
{
  private DebugFrame frame = null;

  public FrameAppender(Layout pLayout)
  {
    setLayout(pLayout);
    frame = DebugFrame.createDebugFrame("Output");
  }

  public boolean requiresLayout()
  {
    return true;
  }

  protected void append(LoggingEvent event)
  {
    frame.print(getLayout().format(event));
  }

  public void close()
  {
    frame.dispose();
  }
}